package com.daotingli.backendprograms.Controller.Author.booktype;


import com.daotingli.backendprograms.Service.Author.booktype.BookTypeService;
import com.daotingli.backendprograms.utils.Result;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
public class BookTypeController {
    @Autowired
    private BookTypeService bookTypeService;

    /**
     * 获取作者id
     */
    @RequestMapping(path = "/user/booktype/getId",
            method = RequestMethod.POST,
            params = {"username","password"})
    public Result getAll(String username, String password) {
        return bookTypeService.getAll(username, password);
    }
    /**
     * 查询作者拥有的所有书籍
     * @param id 作者id
     * @return 书籍名称
     */
    @RequestMapping(path = "/user/booktype/bookAll",
            method = RequestMethod.POST,
            params = {"id"})
    public Result getAllBooks(int id) {
        return bookTypeService.getAllBooks(id);
    }
    /**
     * 查询作者拥有的书籍id
     * @param id 作者id
     * @return 书籍id
     */
    @RequestMapping(path = "/user/individual/getAuthorBookIDs",
            method = RequestMethod.POST,
            params = {"id"})
    public Result getAuthorBookIDs(int id){
        return bookTypeService.getAuthorBookIDs(id);
    }
    /**
     * 查询每本的标签
     * @param id 书籍id
     * @return 标签列表
     */
    @RequestMapping(path = "/user/booktype/bookTag",
            method = RequestMethod.POST,
            params = {"id"})
    public Result getBookTag(int id){
        return bookTypeService.getBookTag(id);
    }
    /**
     * 获取作者全部信息
     * data:{
     *     "id": "作者id",
     *     "username": "作者名称",  // select * from t_user
     *     "password": "密码"
     *     "userphone": "手机号"
     *
     *      bookData:[{
     *           "bookid": "书籍id"
     *           "author_id": "作者id"
     *           "bookname": "书籍名称"  // select * from book
     *           "book_state": "书籍状态"
     *
     *           "tagData:"[
     *              {
     *                  id; //类型id  select * from book_type_Veiw
     *                  type:}
     *              ]
     *           "BookPartData[]": [
     *                {
     *                  章节id： "章节id",
     *                  bookid: "书籍id"
     *                 "chapter": "章节名称"  select *  from book_part
     *                  prat:"内容"  //*** 单独查询 通过 作者id 书籍id 章节id
     *                 }],
     *       }],
     *         ......
     * }
     */
    /***
     * 获取作者的全部信息
     */
    @RequestMapping(path = "/user/booktype/getAuthorInfo",method = RequestMethod.POST,params = {"id"})
    public Result getAuthorInfo(int id){
        return bookTypeService.getAuthorInfo(id);


    }


}

